<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$is_language?'價格節點':'Setting price'}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }

        /*列表处的样式*/
        .weui-cells {
            margin-top: 0.7rem;
            font-size: 0.7rem;
        }

        .weui-cells:first-child {
            margin-top: 0;
        }

        .weui-cell {
            padding: 0.4rem 0.5rem;
        }

        /*.weui-cell__hd {*/
        /*width: 6.4rem;*/
        /*font-size: 0.6rem;*/
        /*}*/

        .weui-cell__bd {
            color: #F44444;
        }

        /*.weui-cell__ft {*/
        /*width: 3rem;*/
        /*}*/

        .time {
            font-size: 0.6rem;
        }

        /*新增节点处的弹出框*/
        .node-dlog {
            position: fixed;
            top: 0px;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            z-index: 100;
            display: none;
        }

        .dlog {
            position: relative;
            top: 7rem;
            left: 0;
            margin: 0 auto;
            padding: 0.5rem;
            width: 13rem;
            height: auto;
            background: #fff;
            border-radius: 0.4rem;
            z-index: 200;
        }

        .node-close {
            position: absolute;
            top: 0rem;
            right: 0rem;
            width: 2rem;
            height: 1.4rem;
            text-align: center;
            line-height: 1.4rem;
            cursor: pointer;
        }

        .nodeForm {
            margin-top: 0.5rem;
            width: 100%;
            font-size: 0.65rem;
        }

        .nodeForm > p {
            display: block;
            width: 100%;
            line-height: 1.6rem;
            margin-top: 0.6rem;
            margin-bottom: 0.4rem;
            text-align: center;
        }

        .nodeForm input[type="number"],
        .nodeForm input[type="text"] {
            padding-left: 0.3rem;
            width: 8.5rem;
            height: 1.4rem;
            border: 0;
            border-bottom: 1px #F44444 solid;
            outline: 0;
        }

        .nodebtn {
            width: 10rem;
            height: 1.5rem;
            color: #FFFFFF;
            background: #F44444;
            border: 0;
            border-radius: 0.2rem;
            outline: 0;
            cursor: pointer;
        }
    </style>
</head>
<body>
<header class="navbar">
    <a href="{:url('main',['id'=>$id])}" class="navbar-item">
        <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
    </a>
    <div class="navbar-center">{$is_language?'價格節點':'Setting price'}</div>
    <div class="navbar-item1">
        <select name="" id="yy">
            <option value="1" {$is_language?'selected':''}>中文</option>
            <option value="0" {$is_language?'':'selected'}>English</option>
        </select>
    </div>
</header>
<div class="content">
    <div class="weui-cell addnode" href="">
        <div class="weui-cell__bd">
            <p><span style="border: 1px solid #F44444;padding: 2px 5px;border-radius: 4px">{$is_language?'新增節點':'Newly added'}+</span></p>
        </div>
    </div>
    <div class="list">
        <!--重复部分开始-->
        {foreach $data as $vo}
        <div class="weui-cells">
            <div class="weui-cell">
                <input type="hidden" name="id" value="{$vo->id}"/>

                <div class="weui-cell__bd">
                    <p class="money">{$is_language?'金額':'money'}{$vo->money}</p>
                </div>
                <div class="weui-cell__ft">
                    <p class="time">{$vo.times|date="Y-m-d H:i",###}</p>
                </div>

                <!--<div class="weui-cell__hd">-->
                <!--<p class="time">{$vo.times|date="Y-m-d H:i",###}</p>-->
                <!--</div>-->
                <!--<div class="weui-cell__bd">-->
                <!--<p class="money">金額{$vo->money}</p>-->
                <!--</div>-->
                <!--<div class="weui-cell__ft">-->
                <!--<p>刪除節點</p>-->
                <!--</div>-->
            </div>
        </div>
        {/foreach}
        <!--重复部分结束-->
    </div>
    <input type="hidden" name="yuyan" value="<?php echo @$is_language?>" id="yuyan">
</div>

<!--新增节点的弹出框开始-->
<div class="node-dlog">
    <div class="dlog">
        <div class="node-close">X</div>
        <form action="" method="post" class="nodeForm">
            <p>
                <label>
                    <span style="color: #F44444;">*</span>{$is_language?'金額':'money'}：
                </label>
                <input type="number" name="money" class="money"/>
            </p>
            <p>
                <label><span style="color: #F44444;">*</span>{$is_language?'時間':'time'}：</label>
                <input type="text" name="times" id="time"/>
            </p>
            <input type="hidden" name="goods_id" value="{$id}">
            <p>
                <input type="button" class="nodebtn" value="{$is_language?'新增節點':'Newly added'}"/>
            </p>
        </form>
    </div>
</div>
<!--新增节点的弹出框结束-->

<script type="text/javascript">
    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
//    $(".weui-cell__ft").click(function () {
//        var id = $(this).parents('.weui-cell').find('input').val();
//        var url = "{:url('del_goods_ruls')}";
//        var yuyan = $('#yuyan').val();
//        if(yuyan==1){
//            $.confirm("確認刪除節點？", function () {
//                $.post(url, {id: id}, function () {
//                    $.toast("操作成功！", function () {
//                        window.location.reload();
//                    })
//                })
//            }, function () {
//                return false;
//            })
//        }else{
//            $.confirm("Confirm delete node?", function () {
//                $.post(url, {id: id}, function () {
//                    $.toast("Successful operation！", function () {
//                        window.location.reload();
//                    })
//                })
//            }, function () {
//                return false;
//            })
//        }
//    })

    $(function () {
        FastClick.attach(document.body);

        //新增节点的弹出框
        $(".addnode").click(function () {
            $(".node-dlog").css('display', 'block');
            $('body').css({
                "overflow-x": "hidden",
                "overflow-y": "hidden"
            });
            //阻止默认
            $("body").on("touchmove", function (event) {
                event.preventDefault;
            }, false);
        });

        $("#time").datetimePicker({
            times: function () {
                return [
                    {
                        values: (function () {
                            var hours = [];
                            for (var i = 0; i < 24; i++) hours.push(i > 9 ? i : '0' + i);
                            return hours;
                        })()
                    },
                    {
                        divider: true,  // 这是一个分隔符
                        content: ':00'
                    }
                ];
            },
            onChange: function (picker, values, displayValues) {
//                console.log(values);
            },
        });


        $('.node-close').click(function () {
            $(".node-dlog").css('display', 'none');
            $('body').css({
                "overflow-x": "auto",
                "overflow-y": "auto"
            });
            //然后点击取消或者确定时再取消body上的绑定
            $("body").off("touchmove");
            location.href = "";
        });

        $(".nodebtn").click(function () {
            $(".nodeForm").submit();
            $(".money").val("");
            $("#time").val("");
        })

    })
</script>
</body>
</html>
